package com.an.redisl;

import java.util.Random;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.an.json.PhoneNumber;

import redis.clients.jedis.Jedis;

public class test2 {

	public static void main(String[] args) {
		Jedis j = new Jedis("127.0.0.1");
		j.hset("ll", "ss", "123");
		j.hset("ll", "ss1", "456");
		j.hset("ll", "ss2", "789");
		j.hset("ll", "ss3", "jqk");
		j.hset("ll", "ww1", "jqk");
		j.hset("ll", "ww2", "jqk");

		Set<String> sets = j.hkeys("ll");

		System.out.println("----------");

		Pattern patter = Pattern.compile("^(phoneNumberY_)\\d{11}$");

		Matcher matcher = patter.matcher("phoneNumberY_15355496937q");
		System.out.println(matcher.matches());

		System.out.println("*************************");
		Pattern pattern2 = Pattern.compile("^(phoneNUmber)[YB]_\\d+");

		for (int i = 0; i < 10; i++) {
			Random r = new Random();
			int a = r.nextInt();
			String s = "";
			if (i % 2 == 0) {
				s += "phoneNUmberB_" + "1244" + a;
			} else {
				s += "phoneNUmberY_" + "24324" + a;
			}
			Matcher matcher2 = pattern2.matcher(s);
			if (matcher2.matches()) {
				System.out.println("当前I=" + i + "，字符串：" + s);
				System.out.println(matcher2.matches());
			} else {
				System.out.println("当前I=" + i + "，字符串：" + s);
				System.out.println(matcher2.matches());
			}
		}
		System.out.println("----------");

	    Pattern pattern = Pattern.compile("^((" + PhoneNumber.YB_B + ")|(" + PhoneNumber.YB_Y + "))\\d+");

		for (int i = 0; i < 10; i++) {
			Random r = new Random();
			int a = r.nextInt();
			String s = "";
			if (i % 2 == 0) {
				s += "phoneNumberB_" + "1244" + a;
			} else {
				s += "phoneNumberY_" + "24324" + a;
			}
			Matcher matcher2 = pattern.matcher(s);
			if (matcher2.matches()) {
				System.out.println("当前I=" + i + "，字符串：" + s);
				System.out.println(matcher2.matches());
			} else {
				System.out.println("当前I=" + i + "，字符串：" + s);
				System.out.println(matcher2.matches());
			}
		}

		System.out.println(sets);
		j.close();
	}
}
